/*
 * Copyright 2016-2017 TVI Go Easy.
 * Created on 2017/5/23 19:13
 */
package com.gitee.mechanic.mybatis.base;

import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableLogic;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.gitee.mechanic.core.constants.Status;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.cache.annotation.EnableCaching;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 实体父类。所有实体直接继承该类。
 *
 * @author mechanic
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@EnableCaching
public abstract class Entity implements Serializable {

    private static final long serialVersionUID = -1993002856545394532L;
    /**
     * 主键
     */
    @TableId
    private Long id;
    /**
     * 记录状态
     *
     * @see Status
     */
    @TableLogic
    @TableField(value = "status", fill = FieldFill.INSERT)
    protected Integer status = Status.ACTIVE;
    /**
     * 创建人
     */
    @TableField(value = "create_user", fill = FieldFill.INSERT)
    protected Long createUser;
    /**
     * 创建时间
     */
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    protected LocalDateTime createTime;
    /**
     * 最后更新人
     */
    @TableField(value = "update_user", fill = FieldFill.INSERT_UPDATE)
    protected Long updateUser;
    /**
     * 最后更新时间
     */
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    protected LocalDateTime updateTime;
}
